# Contributor: goodspb <goodspb.luo@gmail.com>
# Maintainer: Adriaan Groenenboom <agboom@pm.me>
pkgname=php8-pdlib
_extname=pdlib
pkgver=1.0.2
pkgrel=1
pkgdesc="PHP 8 extension for Dlib"
url="https://github.com/goodspb/pdlib"
arch="all !ppc64le" # build fails https://github.com/goodspb/pdlib/issues/19
license="MIT"
depends="php8-common dlib"
makedepends="php8-dev php8-bz2"
source="php-$_extname-$pkgver.tar.gz::https://github.com/goodspb/$_extname/archive/v$pkgver.tar.gz
	https://github.com/goodspb/pdlib/commit/a31d3bc709321b784ecd93c983b476a0a298bfa0.patch"
builddir="$srcdir/$_extname-$pkgver"

#disable check on s390x as Frontal face detection failling
[ "$CARCH" = "s390x" ] && options="!check"

build() {
	phpize8
	./configure --prefix=/usr --with-php-config=php-config8
	make
}

check() {
	# Tests require bz2 extension which is not bundled
	local _modules=/usr/lib/php8/modules
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test \
		TESTS=--show-diff SKIP_ONLINE_TESTS=1 \
		PHP_TEST_SHARED_EXTENSIONS=" \
		-d extension=$_modules/bz2.so \
		-d extension=modules/$_extname.so"
	php8 -dextension=modules/$_extname.so --ri $_extname
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	local _confdir="$pkgdir"/etc/php8/conf.d
	install -d $_confdir
	echo "extension=$_extname" > $_confdir/$_extname.ini
}

sha512sums="7222eeaedad8bfe8d0deb327c4d1deaea172994cfb2f2d43fb10f6b862ccc56e05bb459e0d2c94ed79f222eed8eb7c1974c15f862549bf563b132b531acf1cd3  php-pdlib-1.0.2.tar.gz
5a910e9fbdd79da1f46f008cacc32494f781ae46c857ea1ef06b98fcc81537e12e773b0948fbd8b7fb15c2cbd2fadd13bcc752344fdcba412fa6f8351162f5b4  a31d3bc709321b784ecd93c983b476a0a298bfa0.patch"
